package com.example.demo.filter;

import org.apache.commons.lang3.StringEscapeUtils;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import java.io.UnsupportedEncodingException;

public class EncodingWapper extends HttpServletRequestWrapper {

    private String ENCODING;

    /**
     * Constructs a request object wrapping the given request.
     *
     * @param request The request to wrap
     * @throws IllegalArgumentException if the request is null
     */
    public EncodingWapper(HttpServletRequest request) {
        super(request);
    }

    public EncodingWapper(HttpServletRequest request, String ENCODING) {
        super(request);
        this.ENCODING = ENCODING;
    }

    @Override
    public String getParameter(String name) {
        String value = getRequest().getParameter(name);
        try {
            //byte [] bytes = value.getBytes("ISO-8859-1");
            //value = new String(bytes, ENCODING);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return value;
    }


}
